From: Georges Basile Stavracas Neto Date: Thu, 31 Dec 2020 17:18:42 +0000 (-0300) Subject: util: Add lerp function X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~616^2^2~549 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=07c970d90c768003f35a0d3f1fb9913d5a2b045d;p=gnome-shell.git util: Add lerp function We're going to lerp a lot in the future, to it's worthy sharing this simple but effective interpolation function. Add Util.lerp(). Part-of: --- diff --git a/js/misc/util.js b/js/misc/util.js index 314d7660f..2da489bbe 100644 --- a/js/misc/util.js +++ b/js/misc/util.js @@ -1,7 +1,7 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported findUrls, spawn, spawnCommandLine, spawnApp, trySpawnCommandLine, formatTime, formatTimeSpan, createTimeLabel, insertSorted, - ensureActorVisibleInScrollView, wiggle */ + ensureActorVisibleInScrollView, wiggle, lerp */ const { Clutter, Gio, GLib, Shell, St, GnomeDesktop } = imports.gi; const Gettext = imports.gettext; @@ -435,3 +435,7 @@ function wiggle(actor, params) { }, }); } + +function lerp(start, end, progress) { + return start + progress * (end - start); +}